<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
class login_controller extends base_controller {
    public $login_model ;
    public function __construct() {
        parent::__construct();
        $this->login_model = new login_model();
    }
    public function indexController(){
       $this->form = $this->login_model->sayHello();
       if($_POST){
//          // echo "here";
//           Magic_Connection_Model::callMethod()->connectionOpen();
//           $username = @$_POST["user_name"];
//           $password = @$_POST["user_password"];
//           $array = Magic_CURD_Model::callMethod()
//            ->defineTable("user_master")
//            ->where("user_name = '".$username."' && user_password = '".$password."' LIMIT 1")
//            ->selectfield(array("user_master_id","group_master_id"))
//            ->debug(true) ;
//            //->magicFetchAssoc();
//           Magic_Connection_Model::callMethod()->connectionClose();
          
     
           Magic_Session_Lib::callMethod()->_setSession("uid",$_POST["user_name"]);
           Magic_Session_Lib::callMethod()->_setSession("role_id",1);
//      
           
            echo  'window.location="'.SITE_URL.'default/default/index";';
            exit ;
           // @ob_start();ob_clean();
        }
    }
   public function logoutController(){
            Magic_Session_Lib::callMethod()->_unsetSession("uid");
            Magic_Session_Lib::callMethod()->_unsetSession("role_id");
            Magic_Common_Model::callMethod()->_pageRedirect(SITE_URL."login/login/index");
        
   }
}
?>